#include <gtest/gtest.h>

#include "hash_table/anagram.h"

class AnagramTest : public ::testing::Test
{
  protected:
    void SetUp() override
    {
        // 初始化代码 (需要时)
    }
};

TEST_F(AnagramTest, AnagramGroup)
{
    std::vector<std::string> datas{"abc", "acb", "ac", "bc", "bca", "a"};
    std::vector<std::vector<std::string>> groups;
    anagramGroup(datas, groups);
    EXPECT_TRUE(groups.size() == 4);
    EXPECT_TRUE(groups[0].size() == 3);
    EXPECT_TRUE(groups[0][0] == "abc");
    EXPECT_TRUE(groups[0][1] == "acb");
    EXPECT_TRUE(groups[0][2] == "bca");
    EXPECT_TRUE(groups[1][0] == "ac");
    EXPECT_TRUE(groups[2][0] == "bc");
    EXPECT_TRUE(groups[3][0] == "a");
}

TEST_F(AnagramTest, AnagramGroupByHashTable)
{
    std::vector<std::string> datas{"abc", "acb", "ac", "bc", "bca", "a"};
    std::vector<std::vector<std::string>> groups;
    anagramGroupByHashTable(datas, groups);
    EXPECT_TRUE(groups.size() == 4);
    EXPECT_TRUE(groups[0][0] == "a");
    EXPECT_TRUE(groups[1][0] == "bc");
    EXPECT_TRUE(groups[2][0] == "ac");
    EXPECT_TRUE(groups[3][0] == "abc");
    EXPECT_TRUE(groups[3][1] == "acb");
    EXPECT_TRUE(groups[3][2] == "bca");
    EXPECT_TRUE(groups[3].size() == 3);
}